package gui;

import java.io.File;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import com.swtdesigner.SWTResourceManager;

import resources.images.ImagesPath;

public class RecordsDialog extends Dialog {

	protected Object result;
	protected Shell shell;
	
	private String records;

	/**
	 * Create the dialog
	 * @param parent
	 * @param style
	 */
	public RecordsDialog(Shell parent, int style) {
		super(parent, style);
	}

	/**
	 * Create the dialog
	 * @param parent
	 */
	public RecordsDialog(Shell parent) {
		this(parent, SWT.NONE);
	}
	
	public RecordsDialog(String records, Shell parent) {
		this(parent, SWT.NONE);
		this.records = records;
	}

	/**
	 * Open the dialog
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		return result;
	}

	/**
	 * Create contents of the dialog
	 */
	protected void createContents() {
		shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
		shell.setLocation(RiskGUI.getNewPosition(getParent()));
		shell.setSize(400, 540);
		shell.setText("Records");
		Composite composite = new Composite(shell, SWT.NONE);
		composite.setSize(400, 512);
		composite.setBackgroundImage(new Image(Display.getDefault(),ImagesPath.getImageStream("mission.png")));
		composite.setBackgroundMode(SWT.INHERIT_DEFAULT);
		Label titleLabel = new Label(composite, SWT.NONE);
		titleLabel.setAlignment(SWT.CENTER);
		titleLabel.setBounds(30, 70, 340, 40);
		String separator = File.separator;
		
		Font titleFont = FontLoader.loadFont(
				shell, 
				"src" + separator + "resources" + separator + "fonts" + separator + "papyrus.ttf", 
				24);
		titleLabel.setFont(titleFont);
//		titleLabel.setFont(SWTResourceManager.getFont("Papyrus", 24, SWT.NONE));
		titleLabel.setText("Records Table");
		Label textLabel = new Label(composite, SWT.WRAP);
		textLabel.setBounds(30, 130, 340, 300);
		textLabel.setAlignment(SWT.CENTER);
		Font textFont = FontLoader.loadFont(
				shell, 
				"src" + separator + "resources" + separator + "fonts" + separator + "papyrus.ttf", 
				14);
		textLabel.setFont(textFont);
//		textLabel.setFont(SWTResourceManager.getFont("Papyrus", 14, SWT.NONE));
		textLabel.setText(records);
		//
	}
	
	public static void main(String[] args){
		Shell shell = new Shell();
		RecordsDialog dialog = new RecordsDialog("You need to conquer", shell);
		dialog.open();
	}

}
